<?php


class Blackbird_Form_Users_Login extends Zend_Form
{
	function __construct($options = null)
	{
		parent::__construct($options);

		$this
			->addElement('hidden', 'redirectUrl')

			->addElement('text', 'username', array(
				'class' => 'important',
				'filters' => array('StripTags', 'StringTrim'),
				'label' => 'Usuario:',
				'maxlength' => 100,
				'required' => true,
				'validators' => array('NotEmpty'),
			))

			->addElement('password', 'password', array(
				'class' => 'important',
				'filters' => array('StripTags', 'StringTrim'),
				'label' => 'Contraseña:',
				'maxlength' => 100,
				'required' => true,
				'validators' => array('NotEmpty'),
			))

			->addElement('checkbox', 'persistent', array(
				'label' => 'Recordarme por una semana.',
			))

			->addElement('button', 'submit', array(
				'label' => 'Ingresar',
				'ignore' => true,
				'type' => 'submit',
			))

			->addElement('button', 'cancel', array(
				'label' => 'Cancelar',
				'ignore' => true,
				'type' => 'button',
				'onclick' => 'history.go(-1)',
			))
			;

		$this->redirectUrl
			->removeDecorator('Label')
			->removeDecorator('HtmlTag');

		$this->persistent
			->removeDecorator('HtmlTag')
			->addDecorator('Label', array(
				'placement' => Zend_Form_Decorator_Abstract::APPEND,
			))
			->addDecorator('HtmlTag', array('tag' => 'dd'))
			;

		$this->submit
			->removeDecorator('DtDdWrapper')
			->addDecorator('HtmlTag', array(
				'class' => 'buttons',
				'openOnly' => true,
				'placement' => Zend_Form_Decorator_Abstract::PREPEND,
				'tag' => 'dd',
			));

		$this->cancel
			->removeDecorator('DtDdWrapper')
			->addDecorator('HtmlTag', array(
				'closeOnly' => true,
				'placement' => Zend_Form_Decorator_Abstract::APPEND,
				'tag' => 'dd',
			));
	}
}

